﻿using System;
using System.Globalization;

namespace Xiety.DtoGenerator
{
	public partial class DtoTemplate
	{
		public DtoData Data { get; set; }

		protected string IfNotNull(string str, string format)
		{
			return String.IsNullOrEmpty(str) ? String.Empty : String.Format(CultureInfo.InvariantCulture, format, str);
		}

		protected string If(bool condition, string text)
		{
			return condition ? text : String.Empty;
		}

		protected bool NotEmpty(string str)
		{
			return !String.IsNullOrEmpty(str);
		}

		public string Generate(string fname, DtoData data)
		{
			if (data == null) throw new ArgumentNullException("data");

			this.Data = data;
			return this.TransformText();
		}
	}
}
